#include "Queue.h"
#include "Customer.h"
#include <fstream>

Queue<Customer> readCustomers() {
  Queue<Customer> customers(MAX_SIZE);
  std::ifstream inFile;
  inFile.open("data.txt");
  if (!inFile) {
    std::cout << "Unable to open file";
    exit(1); // terminate with error
  }

  int count = 0;
  inFile >> count;
  if (count < 0) {
    std::cout << "Invalid number of customers";
    exit(1); // terminate with error
  }

  for (int i = 0; i < count; i++) {
    Customer customer;
    inFile >> customer;
    customers.enqueue(customer);
  }

  inFile.close();
  return customers;
}
